Repository navigation
Conversation
With the default Auto stabilization mode, preview stabilization is turned on whenever the lens supports it, including in image-only capture mode, where no video can be recorded. Preview stabilization crops the field of view. In front camera testing, image-only stills were cropped by about 1.16x in each dimension and scaled back up to full size, which made them visibly softer with no change in exposure or gain. In image-only mode, StabilizationMode.AUTO now resolves to OPTICAL when the lens supports it and to OFF otherwise. Other capture modes are unchanged, and explicitly selecting StabilizationMode.ON still enables preview stabilization in image-only mode. The resolution logic moves out of CameraXCameraSystem into a top-level function so that it can be unit tested. Optical stabilization now also turns preview and video stabilization off explicitly. It previously left them unset, so the camera's default applied. On a device whose default enables video stabilization when no video capture use case is attached, an image-only session with optical stabilization ran with video stabilization on.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a dedicated utility, resolveStabilizationMode, to centralize and improve the logic for determining camera stabilization modes. Key changes include ensuring that 'AUTO' stabilization avoids preview stabilization in 'IMAGE_ONLY' mode to prevent unnecessary image cropping, and updating CameraSession to explicitly disable preview stabilization when optical stabilization is active. The PR also includes comprehensive unit tests in StabilizationModeResolutionTest.kt and CameraXCameraSystemTest.kt, along with updated documentation in README.md. I have no further feedback to provide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With the default Auto stabilization mode, preview stabilization is turned on whenever the lens supports it, including in image-only capture mode, where no video can be recorded. Preview stabilization crops the field of view. In front camera testing, image-only stills were cropped by about 1.16x in each dimension and scaled back up to full size, which made them visibly softer with no change in exposure or gain.
This PR stops Auto from choosing preview stabilization in image-only mode.
Changes
StabilizationMode.AUTOresolves toOPTICALwhen the lens supports it and toOFFotherwise. Other capture modes are unchanged.StabilizationMode.ONstill enables preview stabilization in image-only mode.CameraXCameraSysteminto a top-levelresolveStabilizationModefunction so that it can be unit tested.Testing
StabilizationModeResolutionTestcovers Auto resolution for each capture mode, frame rate constraints, and explicitly requested modes.CameraXCameraSystemTestadds tests for Auto, explicit On, and explicit Optical in image-only mode. The stabilization tests pass on a physical device with optical stabilization on the back camera, and on an emulator without optical stabilization.